package com.theme.passport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.utils.Query;
import com.theme.passport.dao.SysFeedbackDao;
import com.theme.passport.entity.SysFeedbackEntity;
import com.theme.passport.service.SysFeedbackService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("sysFeedbackService")
public class SysFeedbackServiceImpl extends ServiceImpl<SysFeedbackDao, SysFeedbackEntity> implements SysFeedbackService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String keyword = (String) params.get("key");
        String type = (String) params.get("type");
        IPage<SysFeedbackEntity> page = this.page(
                new Query<SysFeedbackEntity>().getPage(params),
                new QueryWrapper<SysFeedbackEntity>()
                        .eq(StringUtils.isNotBlank(type), "type", type)
                        .like(StringUtils.isNotBlank(keyword), "description", keyword)
                        .orderByDesc("create_time")
        );
        return new PageUtils(page);
    }

}